Skip to content

pgvector-go: admin extension status, postgres/pgvector, integration tier - #42

Merged
JaimeStill merged 8 commits into
mainfrom
pgvector-go
Nov 25, 2026
Merged

JaimeStill merged 8 commits into
mainfrom
pgvector-go

Conversation

@JaimeStill

Copy link
Copy Markdown
Contributor

v1.data.extensions · task 4/5 · pgvector-go

Summary

  • admin reports extensions. admin.Status has an extensions list, and Ready is false
    whenever a declared extension doesn't match the database.
  • New module go-database/postgres/pgvector. It holds ParseMetric over sqlate's metric
    table. It wraps no pgvector-go type: its package doc shows applications using pgvector-go
    directly.
  • First live tests. go-database has a test-only compose PostgreSQL on 5438, using a copy of
    sqlate's pgvector image, and an integration tier run locally by mise run acceptance.
  • Upgrades. go-database is on sqlate v0.8.0, claude-plugins 0.24.0 and mise-action v5.3.0.
    Its currency.sh is now sqlate's script, so it also checks the image and the pgvector ARG.
  • sqlate gets a goal-record-only branch. This task touches only go-database, but the goal's
    record lives in sqlate, so sqlate's pgvector-go branch carries just that file.

Core changes

  1. admin's extension status. Readiness now covers extensions as well as sets: pending, not
    offered by the image, and no update path all clear Ready. The last two errors wrap
    ErrConflict and keep sqlate's error in the chain. Start logs
    extension pending; applying before it applies.

    type ExtensionStatus struct { Name string; Removed bool; Installed, Default string; Pending bool }
    // Status gains: Extensions []ExtensionStatus `json:"extensions"` (never nil)
  2. postgres/pgvector. The package imports only the standard library and sqlate's
    postgres/pgvector. pgvector-go, pgx and sqlate/postgres are required only by its tests.

    type Metric = sqlvector.Metric
    var ErrUnknownMetric = errors.New("unknown pgvector metric")
    func ParseMetric(name string) (Metric, error)
  3. Integration tier. It runs three live tests:

    • admin.Start installs vector at the image's default on a fresh database, and Status
      reports it installed and ready.
    • A vector column round-trips pgvector-go values and NULL through sql.Null[pgvector.Vector].
    • The test data is chosen so l2, cosine and inner product each pick a different nearest row.

    The check now vets, fixes and lints with -tags integration.

Verify

mise run check: ✓ go-database (., postgres, postgres/pgvector, tagged vet/fix/lint,
lint-context, lint-references); ✓ sqlate

In go-database:

  1. mise run currency → prints nothing, exit 0.
  2. mise run db:up, then
    docker compose exec -T postgres psql -U app -d app -Atc "select default_version from pg_available_extensions where name='vector'"
    → 0.8.7. Then mise run db:down.
  3. mise run acceptance → the stack comes up, all three live tests pass, the stack comes down,
    exit 0.
  4. GOFLAGS=-timeout=1ns mise run acceptance → exit 1, the compose log is printed, and the
    stack still comes down.
  5. Set ARG PGVECTOR_VERSION=0.8.6 by hand, run mise run currency → it reports
    pgvector/pgvector 0.8.6 -> 0.8.7 and exits 1. Revert the ARG.

Decided without you

  1. Dropped go-database's currency.sh comment on failing scans. The brief said to keep it,
    but it isn't one of the five permitted comment kinds. sqlate's header line ("A scan command
    that fails fails currency.") states the behavior, so the script stays byte-identical to
    sqlate's. This was the spec-reviewer's one gap.
  2. The check runs vet, fix and lint once, with -tags integration. These passes replaced the
    untagged ones instead of running alongside them. The tagged pass also covers every untagged
    file.
  3. admin's own ExtensionStatus type with JSON tags. sqlate's type has no tags, so its JSON
    keys would be capitalized.
  4. Status passes an I/O error from reading extensions through unwrapped, as it does an
    aborted operation. A removed extension that is still installed logs the same pending line.
  5. The admin live test uses pgtest.Create, not MigratedWith. MigratedWith would install
    vector before Start ran, so Start wouldn't be what installed it.
  6. The standards review made two tests fail when the metric list changes size. Before, they
    passed silently on an empty or shrunk list.
  7. Editor: Decisions dropped because the code or docs now state them:
    • "go-database's module … uses pgvector-go's root module …" (superseded);
    • removed-but-installed is pending (in sqlate's migrate docs);
    • go-database copies sqlate's Dockerfile and ARG check (built, and in the README);
    • three of this task's four new lines (ParseMetric, the readiness and ErrConflict rule,
      the integration tier).
  8. Pending edits added:
    • The sqlate-test-tier backlog goal now covers go-database too, since neither repository has
      a CI integration job.
    • A new backlog goal, sqlate-extension-match: admin's readiness re-derives sqlate's
      unexported classify rule.
    • The postgres-extensions.md items are merged, for principles to promote.

Redirects and escalations

  1. Plan round 1: Q1 revised. go-database wraps no pgvector-go type, and MetricNamed is named
    ParseMetric.

Merge danger: one-way door for both tags. Accepting authorizes these steps:

  1. Merge sqlate's record-only pgvector-go branch.
  2. Merge go-database's branch (merge waits on CI), confirm CI is green, and tag v0.13.0.
  3. A pgvector-go-fix branch swaps postgres/pgvector's replace for the v0.13.0 pin, merges
    on green CI, and then tags postgres/pgvector/v0.1.0.

Once pushed, Status.Extensions, its JSON, the readiness and ErrConflict rule, ParseMetric
and ErrUnknownMetric are public. Blast radius: go-database consumers, starting with
capstone-athena.

Needs you: none

…ness

- admin.Status gains Extensions (json "extensions"), one admin.ExtensionStatus
  per declaration in declared order; empty, never nil, when none is declared.
  admin declares its own entity because migrate.ExtensionStatus has no json
  tags.
- Status.Ready is false when a declaration does not match: an active one
  matches only when installed at a non-empty default, a removed one only when
  not installed. This covers pending, unavailable, and no-update-path.
- conflict() wraps ErrExtensionUnavailable and ErrNoUpdatePath in ErrConflict;
  settle() marks the service not ready on both.
- Start's pending log reads Migrator.Extensions after the dirty-set check and
  logs "extension pending; applying" (extension, installed, default) before
  the pending sets; removed pending declarations are logged the same way.
- Status reads sets first, then extensions; an Extensions read error is
  returned unwrapped (it is I/O, not a schema conflict).
- Changelog Unreleased records the sqlate v0.8.0 requirement and the above.
  README unchanged: it does not document Status or readiness.
…c with ParseMetric

A new nested module, github.com/standards-lab/go-database/postgres/pgvector,
requiring only sqlate's postgres/pgvector v0.1.0. Its package exports
ParseMetric and ErrUnknownMetric, and Metric as a type alias of sqlate's
pgvector.Metric (imported as sqlvector), so it declares no type of its own.
ParseMetric matches a name exactly against sqlate's Metrics() and refuses
any other with an error wrapping ErrUnknownMetric and quoting the name,
before any I/O.

doc.go shows pgvector-go used directly (NewVector for a parameter,
sql.Null[pgvector.Vector] with Slice for a nullable column, domain types
on []float32) and a configured metric's OpClass and Operator in use, and
limits importing the module the way a provider's is.

GO_MODULES and go.work include the module; README and STANDARDS.md name
it and its dependency line; its CHANGELOG.md records [Unreleased]. The
release workflow derives the changelog from the tag prefix, so
postgres/pgvector/v0.1.0 needs no change there.
…s image

compose.yml names the project go-database and includes compose/postgres.yml,
which publishes 127.0.0.1:${POSTGRES_PORT:-5438} and keeps its data on tmpfs as a
test-only harness. compose/postgres/Dockerfile is sqlate's canonical image copied
verbatim (postgres:19.0-alpine, pgvector 0.8.7 from source, its HEALTHCHECK).
mise run db:up / db:down drive compose directly; there is no db:reset, since
tmpfs leaves nothing to drop. GO_DATABASE_DSN follows POSTGRES_PORT.

scripts/currency.sh is sqlate's, verbatim: it adds the image-line, Dockerfile
FROM and source-ARG checks, with crane (aqua:google/go-containerregistry
0.22.1) installed by mise. The old script's paragraph on failing scans
explained a mechanism, which no allowed comment kind covers; sqlate's header
already states the behavior ("A scan command that fails fails currency") as
part of the script's documentation, so the paragraph is dropped.

README documents the stack; STANDARDS.md's release-and-ci line names it.
…ise run acceptance

The tier sits behind the integration build tag and uses GO_DATABASE_DSN and
sqlate's postgres/pgtest:

- admin.Start over a migrator declaring vector activates it in a scratch
  database made with pgtest.Create, where vector is absent first; Status
  then reports it installed at the image default, not pending, and Ready.
- A vector column round-trips pgvector.NewVector values and a NULL through
  sql.Null[pgvector.Vector] and Slice, over pgtest's pgx database/sql pool.
- Each metric of sqlate's Metrics, resolved by ParseMetric, orders a
  nearest-neighbor query to a different row (l2, cosine and inner product
  disagree on the data); a metric with no expected row fails the test.

mise run integration runs the tier against a running stack; mise run
acceptance runs db:up, integration, and db:down whatever the result, and
prints docker compose logs on failure.

The check's vet, fix and lint run with the integration tag for every module
in place of their untagged runs, since the tagged run covers every untagged
file too; build and test stay untagged.

go.mod gains, for the tests only, pgvector-go v0.4.1, go-database v0.13.0,
sqlate v0.8.0 and sqlate's postgres v0.9.0, with a replace of go-database
to ../.. until v0.13.0 is tagged. The README, doc.go and STANDARDS.md name
the tier and its test-only requirements; the CHANGELOG records no tests, so
it is unchanged.
…fy's names the extension at fault (tests-and-docs, comments); the metric tests fail on an empty or changed metric table (tests-and-docs)
@JaimeStill
JaimeStill merged commit 280741e into main Nov 25, 2026
1 check passed
@JaimeStill
JaimeStill deleted the pgvector-go branch November 25, 2026 01:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant